Update skytraq UTC/GPS time handling.
authorRobert Lipe <robertlipe@gpsbabel.org>
Wed, 28 Jun 2017 19:10:37 +0000 (14:10 -0500)
committerRobert Lipe <robertlipe@gpsbabel.org>
Wed, 28 Jun 2017 19:10:37 +0000 (14:10 -0500)
Update tables with latest two constant changes.
Add command line option for overriding this.

reference/skytraq-artificial.gpx
skytraq.cc
xmldoc/formats/options/skytraq-gps_utc_offset.xml [new file with mode: 0644]

index d9ce07151f681a4dc6d2b3cec2cb0b56ead7f879..16412ee78820408b8728e43084e38cda9db9a4f7 100644 (file)
       </trkpt>
       <trkpt lat="47.547749767" lon="9.679499575">
         <ele>435.413042</ele>
-        <time>2019-03-30T23:59:44Z</time>
+        <time>2019-03-30T23:59:42Z</time>
         <speed>2.777778</speed>
         <name>TP0039</name>
       </trkpt>
       <trkpt lat="47.547749767" lon="9.679499575">
         <ele>435.413042</ele>
-        <time>2019-04-01T23:59:44Z</time>
+        <time>2019-04-01T23:59:42Z</time>
         <speed>27.777779</speed>
         <name>TP0040</name>
       </trkpt>
       <trkpt lat="47.547749767" lon="9.679499575">
         <ele>435.413042</ele>
-        <time>2019-04-06T01:37:52Z</time>
+        <time>2019-04-06T01:37:50Z</time>
         <speed>27.777779</speed>
         <name>TP0041</name>
       </trkpt>
       <trkpt lat="47.547749767" lon="9.679499575">
         <ele>435.413042</ele>
-        <time>2019-04-06T23:59:42Z</time>
+        <time>2019-04-06T23:59:40Z</time>
         <speed>55.555557</speed>
         <name>TP0042</name>
       </trkpt>
       <trkpt lat="47.547749767" lon="9.679499575">
         <ele>435.413042</ele>
-        <time>2019-04-06T23:59:43Z</time>
+        <time>2019-04-06T23:59:41Z</time>
         <speed>55.555557</speed>
         <name>TP0043</name>
       </trkpt>
index 914ecd27b95a14c07d1f22d48d9ff65ed6810a6c..ec7c959cc99763d8fc649816dccc9c9ef1c16583 100644 (file)
@@ -68,6 +68,7 @@ static char* opt_dump_file = 0;               /* dump raw data to this file (optional) */
 static char* opt_no_output = 0;                /* disable output? (0/1) */
 static char* opt_set_location = 0;     /* set if the "targetlocation" options was used */
 static char* opt_configure_logging = 0;
+static char* opt_gps_utc_offset = 0;
 
 static
 arglist_t skytraq_args[] = {
@@ -111,6 +112,10 @@ arglist_t skytraq_args[] = {
     "no-output", &opt_no_output, "Disable output (useful with erase)",
     "0", ARGTYPE_BOOL, ARG_NOMINMAX
   },
+  {
+    "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)",
+    "0", ARGTYPE_INT, ARG_NOMINMAX
+  },
   ARG_TERMINATOR
 };
 
@@ -124,6 +129,10 @@ arglist_t skytraq_fargs[] = {
     "last-sector", &opt_last_sector, "Last sector to be read from the file (-1: read till empty sector)",
     "-1", ARGTYPE_INT, "-1", "65535"
   },
+  {
+    "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)",
+    "0", ARGTYPE_INT, ARG_NOMINMAX
+  },
   ARG_TERMINATOR
 };
 
@@ -587,6 +596,12 @@ gpstime_to_timet(int week, int sec)
   time_t gps_timet = 315964800;     /* Jan 06 1980 0:00 UTC */
   gps_timet += (week+1024)*7*SECONDS_PER_DAY + sec;
 
+  int override = atoi(opt_gps_utc_offset);
+  if (override) {
+    gps_timet -= override;
+    return gps_timet;
+  }
+
   /* leap second compensation: */
   gps_timet -= 13;  /* diff GPS-UTC=13s (valid from Jan 01 1999 on) */
   if (gps_timet >= 1136073600) {    /* Jan 01 2006 0:00 UTC */
@@ -598,6 +613,14 @@ gpstime_to_timet(int week, int sec)
   if (gps_timet >= 1341100800) {    /* Jul 01 2012 0:00 UTC */
     gps_timet--;  /*   GPS-UTC = 16s      */
   }
+  if (gps_timet >= 1435708800) {    /* Jul 01 2015 0:00 UTC */
+    gps_timet--;  /*   GPS-UTC = 17s      */
+  }
+  if (gps_timet >= 1483228800) {    /* Jan 01 2017 0:00 UTC */
+    gps_timet--;  /*   GPS-UTC = 18s      */
+  }
+  // Future: Consult http://maia.usno.navy.mil/ser7/tai-utc.dat
+  // use http://www.stevegs.com/utils/jd_calc/ for Julian to UNIX sec
 
   return gps_timet;     /* returns UTC time */
 }
diff --git a/xmldoc/formats/options/skytraq-gps_utc_offset.xml b/xmldoc/formats/options/skytraq-gps_utc_offset.xml
new file mode 100644 (file)
index 0000000..7be7264
--- /dev/null
@@ -0,0 +1,18 @@
+<para>
+gps_utc_offset is used to override the built-in table of offsets of
+the offset between GPS time and UTC time. This chipset reports only 
+GPS time to the host and relies on software to know every time an adjustment
+is made. Since GPS time offsets can change without a new version of GPSBabel
+is released, those that care about total accuracy can override it.
+
+<screen>
+<command>gpsbabel</command>
+-i skytraq.bin,gps_utc_offset=15 -f <replaceable>filename.bin</replaceable>
+</screen>
+
+Indicates that GPS is ahead of UTC by fifteen seconds, as was the case in 2009.
+</para>
+
+<para>
+Consult formal eplanation of <ulink url="http://tycho.usno.navy.mil/leapsec.html">GPS time vs. UTC time</ulink> if you're into that.
+</para>